import request from '@/utils/request'
import { HAIGOU_BASE_URL } from '@/dictionaries'

export const postCheckPhoneApi = (tel) => request.post(`${HAIGOU_BASE_URL}/user/docheckphone`, { tel })
export const postSendPhoneApi = (tel) => request.post(`${HAIGOU_BASE_URL}/user/dosendmsgcode`, { tel })
export const postCheckCodeApi = (tel, telcode) => request.post(`${HAIGOU_BASE_URL}/user/docheckcode`, { tel, telcode })
export const postRegistryApi = (tel, password) => request.post(`${HAIGOU_BASE_URL}/user/dofinishregister`, { tel, password })
export const postLoginApi = (loginname, password) => request.post(`${HAIGOU_BASE_URL}/user/login`, { loginname, password })
export const postUserInfoApi = (params) => request.get(`${HAIGOU_BASE_URL}/user/info`, { params })
export const getGoodListApi = (params) => request.get(`${HAIGOU_BASE_URL}/pro/list`, { params })
export const getRecommentListApi = (params) => request.get(`${HAIGOU_BASE_URL}/pro/recommendlist`, { params })

export const postCarGoodItemApi = (params) => request.post(`${HAIGOU_BASE_URL}/cart/add`, params, { showTips: true })
export const postCarGoodItemDeleteApi = (params) => request.post(`${HAIGOU_BASE_URL}/cart/remove`, params, { showTips: true })
export const postCarGoodItemNumApi = (params) => request.post(`${HAIGOU_BASE_URL}/cart/updatenum`, params, { showTips: true })
export const postCarGoodItemFlagApi = (params) => request.post(`${HAIGOU_BASE_URL}/cart/selectone`, params, { showTips: true })
export const postCarGoodsFlagApi = (params) => request.post(`${HAIGOU_BASE_URL}/cart/selectall`, params, { showTips: true })

export const getBannerListApi = () => request.get(`${HAIGOU_BASE_URL}/banner/list`)
export const getGoodDetailApi = (id) => request.get(`${HAIGOU_BASE_URL}/pro/detail/${id}`)
export const getCarGoodListApi = (userid) => request.post(`${HAIGOU_BASE_URL}/cart/list`, { userid })
